package com.apes.fn.scm.merchant.account.model;


import com.apes.framework.jpa.BaseModel;
import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.Model;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import com.apes.framework.plugin.fsm.FsmFlowInstance;
import com.apes.framework.plugin.outbox.annotation.OutBoxExclude;
import com.apes.framework.util.ApesConst;
import com.apes.scm.masterdata.frame.model.Dept;
import com.apes.scm.masterdata.party.model.PartyRole;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.util.Date;

/**
 * @BelongsProject: apes-server
 * @BelongsPackage: com.apes.fn.scm.merchant.account
 * @ClassName: MerchantSettlement
 * @Author: pyb
 * @CreateTime: 2021-09-29 16:19
 * @Description: 赋能商户结算对账单2.0
 * @Version: 1.0
 */
@OutBoxExclude
@Getter
@Setter
@SelectBeforeUpdate
@DynamicUpdate
@DynamicInsert
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = MerchantFixedLoss.CONST_TABLE_NAME)
public class MerchantFixedLoss extends Model {
    public static final String CONST_TABLE_NAME = "merchant_fixed_loss";

    @Id
    @Column(name = "id")
    @ApesGenerator(code = CONST_TABLE_NAME, name = "赋能商户结算对账单定损")
    @Comment("编码")
    private long id;

    @NotNull
    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "company_id", referencedColumnName = "id")
    @Comment("公司编码")
    private PartyRole company; //公司

    @NotNull
    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "dept_id", referencedColumnName = "id")
    @Comment("部门编码")
    private Dept dept; //部门

    @Column(name = "car_license", length = 255)
    @Comment("车牌")
    private String carLicense;

    @Comment("收款金额")
    @Column(name = "collection_amount")
    private double collectionAmount;

    @Comment("调整金额")
    @Column(name = "adjustment_amount", columnDefinition = ApesConst.FIELD_MONEY_16_4_0)
    private double adjustmentAmount = 0;

    @Comment("门店待回款金额")
    @Column(name = "store_amount", columnDefinition = ApesConst.FIELD_MONEY_16_4_0)
    private double storeAmount = 0;

    @Comment("平台待回款金额")
    @Column(name = "platform_amount", columnDefinition = ApesConst.FIELD_MONEY_16_4_0)
    private double platformAmount = 0;

    @Comment("平台待回款金额")
    @Column(name = "payment_amount", columnDefinition = ApesConst.FIELD_MONEY_16_4_0)
    private double paymentAmount = 0;

    @Column(name = "bookkeeping_date")
    @Comment("记账日期")
    private Date bookkeepingDate;

    @Column(name = "source")
    @Comment("来源单号")
    private String source;

    @Column(name = "source_business_type", length = 32)
    @Comment("来源单据类型")
    private String sourceBusinessType;

    @Comment("备注")
    @Column(name = "remark")
    private String remark;


}
